<template>
  <div class="shouye">
    <hyy-header></hyy-header>
    <section>
      <router-link :to="{name: 'shouye/tuijian'}">推荐</router-link>
      <router-link :to="{name: 'shouye/zeidianji'}">贼惦记</router-link>
      <router-link :to="{name: 'shouye/meishi'}">美食</router-link>
      <router-link :to="{name: 'shouye/muying'}">母婴</router-link>
    </section>
    <router-view></router-view>
    <hyy-footer></hyy-footer>
    <div class="up" @click="toTop()" v-if="isUP">
      <img src="../../assets/img/shouye/tuijian-xuanliyanzhuang/toTop.png"/>
    </div>
  </div>
</template>
<script>
  import HyyHeader from '../HyyHeader/header.vue'
  import HyyFooter from '../HyyFooter/footer.vue'
  export default {
    components: {
      HyyHeader,
      HyyFooter
    },
      data () {
        return {
          isUP: false,
        }
      },
      mounted() {
          window.addEventListener('scroll', this.menu)
      },
      methods: {
        toTop () {
          if(document.documentElement){
            document.documentElement.scrollTop = 0;
          }else{
            document.body.scrollTop = 0;
          }
        },
        menu() {
          this.scroll = document.documentElement.scrollTop || document.body.scrollTop;
          if(this.scroll > 0){
            //显示 a 标签
            this.isUP = true;
          }else{
            //隐藏 a 标签
            this.isUP = false;
          }
        },
        top () {
          window.scrollTo(0,0)
        },
      },
    created () {
      this.top();
    },
  }
</script>
<style scoped>
  .shouye {
    position: relative;
    width: 100%;
  }
  section{
    display: flex;
    padding: 0.3rem 0;
    position: fixed;
    width: 100%;
    z-index: 10;
    top: 2rem;
    width: 100%;
    background: #fff;
  }
  section a {
    flex: 1;
    text-align: center;
    font-family: MicrosoftYaHei;
    font-size: 0.8rem;
    font-weight: normal;
    font-stretch: normal;
    line-height: 1rem;
    color: #333333;
  }
  .router-link-active{
    color: #e53e42;
  }
  .up {
    width: 1.5rem;
    position: fixed;
    bottom: 3rem;
    right: 0.3rem;
  }
  .up img {
    width: 100%;
  }
</style>
